<template>
    <div id="app">
        <router-view />
    </div>
</template>
<script>
import permission from './permission';
import {mapState} from 'vuex';
export default {
    name: 'app',
    created() {
        if (this.userToken) {
            permission();
            return;
        }
        this.$router.push('/');
    },
    computed: {
        ...mapState('user', {
            userToken: 'userToken'
        })
    },
    watch: {
        $route: {
            immediate: true,
            handler(val) {
                if (val && val.meta && val.meta.title) {
                    document.title = `ERP-${val.meta.title}`;
                } else {
                    document.title = 'ERP';
                }
            }
        }
    }
};
</script>
<style lang="scss">
.text-block-wrapper {
    display: flex;
    flex-flow: row wrap;
    .text-block {
        margin-bottom: 24px;
        display: flex;
        flex-flow: row nowrap;
    }
    .text-block + .text-block {
        margin-left: 20px;
    }
}
.text-title {
    color: #909399;
}
.text-content {
    color: #606266;
}
</style>
